package clientUtilGUI;

import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;

import clientMain.Main;
import clientView.Contact_View;
import clientView.Help_View;

public class Tab_Help extends JToolBar implements ActionListener {
	private JButton btnLienHe;
	private JButton btnRegulation;


	public Tab_Help(){
		setFloatable(false);
		setOrientation(JToolBar.HORIZONTAL);
		setMargin(new Insets(0, 6, 0, 2));
		
		btnRegulation = new JButton(UtilityGUI.subMenuReg, new ImageIcon("src/image/Blue NoteBook.png"));
		btnRegulation.addActionListener(this);
		btnRegulation.setVerticalTextPosition(JButton.BOTTOM);
		btnRegulation.setHorizontalTextPosition(JButton.CENTER);
		add(btnRegulation);

		btnLienHe = new JButton(UtilityGUI.subMenuLienHe,new ImageIcon("src/image/LienHe.png"));
		btnLienHe.setVerticalTextPosition(JButton.BOTTOM);
		btnLienHe.setHorizontalTextPosition(JButton.CENTER);
		btnLienHe.addActionListener(this);
		add(btnLienHe);
		
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource()== btnRegulation){
			int index = Main.jTabbedPane.positionTab(UtilityGUI.subMenuReg);
			if(index == -1){
				Main.jTabbedPane.addTab(new Help_View(), UtilityGUI.subMenuReg);
				Main.jTabbedPane.setSelectedIndex(Main.jTabbedPane.getTabCount()-1);
			}else{
				Main.jTabbedPane.setSelectedIndex(index);
				return;
			}
		}
		else if(e.getSource()==btnLienHe){
			int index = Main.jTabbedPane.positionTab(UtilityGUI.tabLienHe);
			if(index == -1){
				Main.jTabbedPane.addTab(new Contact_View(), UtilityGUI.tabLienHe);
				Main.jTabbedPane.setSelectedIndex(Main.jTabbedPane.getTabCount()-1);
			}else{
				Main.jTabbedPane.setSelectedIndex(index);
				return;
			}
		}
		
	}
}
